﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Leikjavefurinn;

namespace Leikjavefurinn.Repo
{
	public class TicTacToeRepo : ITicTacToeRepo
	{
		private GameDBDataContext _db = new GameDBDataContext();

		public IEnumerable<Game> AllGames()
		{
			return (from g in _db.Games select g).ToList();
		}

		public IEnumerable<TicTacToe> AllTickTacToe()
		{
			return (from t in _db.TicTacToes select t).ToList();
		}

		/*Förum í gegnum leikina og ef það er einhver leikur 
		 sem hefur sama id og sent var inn þá veljum við hann*/
		public TicTacToe GetGameByID(Guid id)
		{
			return (from game in _db.TicTacToes
					where game.GameId == id
					select game).SingleOrDefault();
		}

		/*
		private GameDBDataContext db = new GameDBDataContext();

			// Á að gera þetta???
		TicTacToe TTT = new TicTacToe();

		public IEnumerable<Game> getGame(string name)
		{
			var games = db.Games.Where(n => n.GameName == name);
			return games;
		}

		public IEnumerable<Game> getActivePlayers()
		{
			var allActivePlayers = (from u in db.Users
									join g in db.Games on u.UserId equals g.UserId
									where g.IsActive == true
									u).All();

			return allActivePlayers;
		}
        

		public void invitePlayers()
		{
            
		}
            
		public void createGame()
		{
			TicTacToe newGame = new TicTacToe();
		}*/


        }

		/*public void setTTTName(string name)
        {
            TTT.GameName = name;
        }*/
	}
